home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: memory allocation using malloc and free
- Date: 28 Feb 96 02:15:47 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.825473747@rscernix>
- References: <4gagll$5rc@bertrand.ccs.carleton.ca> <danpop.824767980@rscernix> <4gbqd7$1em@inet-nntp-gw-1.us.oracle.com> <4gd8ngINNp5i@keats.ugrad.cs.ubc.ca> <danpop.824952492@rscernix> <825456804snz@genesis.demon.co.uk>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- Lawrence Kirby <fred@genesis.demon.co.uk> writes:
-
- >In article <danpop.824952492@rscernix> danpop@mail.cern.ch "Dan Pop" writes:
- >
- >>For this particular discussion, the limit is 32K - 1. And no more than
- >>one object of this size. (Actually the phrasing is a little bit silly,
- >>because it doesn't even guarantee that every program containing such an
- >>object can be compiled and run, it requires that at least one program
- >>should be correctly translated):
- >
- >The wording may not guarantee much but it is not silly. All real systems
- >have memory limit on a running program. If the wording guaranteed that
- >every program containing such an object (and in the absense of other
- >violations) can be compiled and run I can show all implementations to be
- >non-conforming. All I have to do is write a program that allocates x lots
- >of, say, 10K blocks and then a 32K-1 block. For any system with limited
- >memory there will be a value of x at which this fails. I may have to perform
- >a lot of trial and error to find x and the value may vary from run to run
- >but sooner or later I will hit a run that fails.
-
- OTOH, an implementation can reject a program containing a single object
- of 10K and still claim conformance because there is one (and only one)
- program which contains a 32K-1 object which is correctly translated, and
- this program is:
-
- main()
- {
- static a[32767];
- return 0;
- }
-
- which works simply because 'a' is optimized away. This makes the
- 32K-1 guarantee useless (as well as the rest of the guarantees in the
- translation limits section).
-
- A better wording should have been used. For this particular limit, the
- standard could have said that the (maximum) sum of all the sizes of the
- objects in _any_ program should be at least 32K-1. Such a wording would
- still guarantee an object of 32K-1 in any program, yet your trick wouldn't
- work.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-